export function formatError(error) {
    if (typeof error === 'object') {
        return [
            error.status,
            error.message
        ].join(': ');
    }
    return error;
}
import {PropTypes} from 'react';
import {getContext} from 'recompose';

/**
 * 为组件引入context中的属性（默认为object类型）
 * @param props 属性名称列表
 * @return {*}
 */
export function context(...props) {
    const contextTypes = {};
    for (const name of props) {
        switch (typeof name) {
        case 'string':
            contextTypes[name] = PropTypes.object;
            break;
        case 'object':
            Object.assign(contextTypes, name);
            break;
        }
    }
    return getContext(contextTypes);
}
